import { PetSkillListPanel } from "../skill/PetSkillListPanel";
import { PetSkillItem } from "../skill/PetSkillItem";
import { ObjCreate } from "../../common/ObjCreate";
import { Language } from "../../../../../extend/language/Language";
import { GlobalClass } from "../../../../../com/mui/core/GlobalClass";
import { ImagesConst } from "../../../resource/ImagesConst";
import { DisplayUtil } from "../../../../common/DisplayUtil";
import { SPetSkill } from "../../../../../Message/Game/SPetSkill";
import { GButton } from "../../../../../com/mui/controls/GButton";
import { Dispatcher } from "../../../../mvc/core/Dispatcher";
import { DataEvent } from "../../../events/DataEvent";
import { EventName } from "../../../mvc/EventName";
//class PetStudySkillListPanel
    
    export  class PetStudySkillListPanel extends PetSkillListPanel
    {
        constructor()
        {
            super();
            this._viewBtnArray = [];
            return;
        }

        public /* override */ init(arg1: Boolean=false): void
        {
            var loc1=null;
            var loc2=null;
            var loc3=null;
            var loc4=0;
            while (loc4 < 14) 
            {
                loc1 = new PetSkillItem();
                loc1.isDig = arg1;
                loc1.setSize(32, 32);
                loc1.y = 3;
                (loc3 = ObjCreate.createGButton(Language.getString(54568), 0, 40, 40, 20, this)).name = loc4.toString();
                loc3.addEventListener(flash.events.MouseEvent.CLICK, this.onViewBtnClickHandler);
                this._viewBtnArray.push(loc3);
                if (loc4 < 12) 
                {
                    loc2 = GlobalClass.getBitmap(ImagesConst.PackItemBg);
                    loc2.x = loc4 * 42;
                    loc1.x = 3 + loc4 * 42;
                    loc3.x = loc4 * 42;
                    if (loc4 < 4) 
                    {
                        loc1.type = 0;
                    }
                    else if (loc4 >= 4 && loc4 < 12) 
                    {
                        loc1.type = 1;
                    }
                }
                else 
                {
                    DisplayUtil.removeMe(loc3);
                }
                loc1.index = loc4;
                _skillItemArray.push(loc1);
                if (loc4 < 12) 
                {
                    loc2.width = 38;
                    loc2.height = 38;
                    this.addChild(loc2);
                    this.addChild(loc1);
                }
                loc1.addEventListener(flash.events.MouseEvent.CLICK, onSkillItemClickHandler);
                ++loc4;
            }
            return;
        }

        protected /* override */ setSkill(arg1: PetSkillItem, arg2: SPetSkill): void
        {
            super.setSkill(arg1, arg2);
            var loc1=arg1.index;
            var loc2=this._viewBtnArray[loc1] as GButton;
            if (arg2) 
            {
                loc2.visible = true;
            }
            else 
            {
                loc2.visible = false;
            }
            return;
        }

        /* internal  */onViewBtnClickHandler(arg1: Object /* flash.events.Event */): void
        {
            var loc1=int((arg1.target as GButton).name);
            var loc2=_skillItemArray[loc1] as PetSkillItem;
            var loc3=loc2.skill.skillId;
            var loc4=loc2.petInfo;
            Dispatcher.dispatchEvent(new DataEvent(EventName.PetSkillViewWindowOpen, {"skillId": loc3, "petInfo": loc4}));
            return;
        }

        /* internal */ /* var */_viewBtnArray: Array<any>;
    }
